package errOnce

import "sync"

type ErrOnce struct {
	o sync.Once
}

func (e *ErrOnce) Do(f func() error) (err error) {
	e.o.Do(func() {
		err = f()
	})
	return err
}

func NewErrOnce() ErrOnce {
	return ErrOnce{
		o: sync.Once{},
	}
}
